package redora.test.rdo.model;

import org.jetbrains.annotations.NotNull;
import redora.api.fetch.Scope;
import redora.db.SQLParameter;
import redora.exceptions.CopyException;
import redora.test.rdo.model.base.JUnitMasterBase;

import java.sql.ResultSet;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

import static java.lang.Boolean.TRUE;
import static redora.db.SQLParameter.yyyyMMdd;
import static redora.db.SQLParameter.yyyyMMddHHMMSS;
import static redora.test.rdo.model.base.JUnitMasterBase.Enumm.Three;

/**
* @author Redora
* @see JUnitMasterBase
*/
public class JUnitMaster extends JUnitMasterBase {

    public static final String DDATETIME = "2009-05-23 12:13:14";
    public static final String DDATE = "2009-05-13";

    public JUnitMaster() {
        //Initializes default values (if any).
        super();
    }

    /**
    * Initializes JUnitMaster using a record in a ResultSet. The JUnitMasterUtil class
    * normally uses this.
    * @param rs (Mandatory) ResultSet object using the field set defined in JUnitMasterSQLBase pointing to the record you want to serialize.
    * @param offset (Mandatory) Usually 0, but if the field set is more then this object's field set you must set the offset.
    * @param scope (Mandatory) The scope of the executed query, like Scope.Table of Scope.Form.
    * @throws CopyException Wrapper for SQLException from accessing the ResultSet
    */
    public JUnitMaster(@NotNull ResultSet rs, int offset, @NotNull Scope scope)
            throws CopyException {
        super(rs, offset, scope);
    }


    public void avoidNull() {
        setNotnull("I am filled");
        setIntegerNotNull(923221);
        setBooleanNotNull(false);
    }

    public void fillMe() throws ParseException {
        avoidNull();
        setIinteger(8);
        setDdate(yyyyMMdd.parse(DDATE));
        setBboolean(TRUE);
        setLlong(12L);
        setDdouble(2.232);
        setEnumm(Three);
        setDdatetime(yyyyMMddHHMMSS.parse(DDATETIME));
    }
}
